const form = document.forms[0]

import ajax from '../utils/ajax'

form.onsubmit = function (e) {
    e.preventDefault()
    ajax('post', '/api/manage/admins/login', {
        uid: form.uid.value,
        pwd: form.pwd.value
    })
        .then(result => {
            if (result.flag) {
                // 获取token
                localStorage.setItem('token', result.token)
                alert('登录成功')
                location.assign('../manage/index.html')
            } else {
                alert(result.msg)
            }
        })

}